package com.xxwy.dependency.scope;

import com.xxwy.dependency.PrototypeUser;
import com.xxwy.dependency.ScopeUser;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * .
 *
 * @author xxwy
 * @date 2021/8/3 0003
 */
public class ScopeProxyModeDemo {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(PrototypeUser.class);
        context.register(ScopeUser.class);
        context.refresh();
        for (int i = 0; i < 5; i++) {
            ScopeUser scopeUser = context.getBean("scopeUser", ScopeUser.class);
            PrototypeUser prototypeUser = context.getBean("prototypeUser", PrototypeUser.class);
            System.out.println(" scopeUser " + scopeUser);
            System.out.println(" scopeUser -> protytype " + scopeUser.getPrototypeUser());
            System.out.println("prototype "+  prototypeUser);
        }
        context.close();
    }
}
